<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@include file="/WEB-INF/mytag.jspf"%>

<!DOCTYPE html>
<html>
<head>
<base href="<%=basePath%>">
<title>套餐管理</title>
<script src="assets/js/package/package.js"></script>
</head>
<body>
	<ol class="am-breadcrumb am-breadcrumb-slash am-padding" style="margin-bottom: 0px;">
		<li><a href="management/index">首页</a></li>
		<li><a href="management/package/index">套餐管理</a></li>
		<li class="am-active">${op}</li>
	</ol>
	<div class="am-g">
		<div class="am-u-md-12">
			<form class="am-form am-form-horizontal" id="form" name="form"  method="post" action="management/package/update">
			<input id="id" name="packageId" type="hidden" value="${t.packageId }">
			<input id="compId" name="compId" type="hidden" value="${t.compId }">
			<input id="state" name="state" type="hidden" value="${t.state }">
			<div class="am-tabs am-margin">
					<ul class="am-tabs-nav am-nav am-nav-tabs">
						<li class="am-active"><a href="javascript:void(0)">基本信息</a></li>
					</ul>
					<div class="am-tabs-bd" style="overflow:visible">
						<div class="am-tab-panel am-active">
							<div class="am-form-group">
								<label class="am-u-md-2 am-text-right am-form-label">套餐名称</label>
								<div class="am-u-md-4 am-u-end">
									<input type="text" id="name" name="name" value="${t.name}" class="am-form-field am-input-sm" maxlength="50">
								</div>
							</div>
							<c:if test="${op!='详情'}">
							<div class="am-form-group">
								<label class="am-u-md-2 am-text-right am-form-label" >请选择服务</label>
								<div class="am-u-md-4 am-u-end">
									<select id="serviceSel" multiple>
									<c:forEach items="${items}" var="i">
  										<option value="${i.serviceItemId}" <c:forEach items='${priceList}' var='entry'><c:if test="${i.serviceItemId == entry.key}">selected</c:if></c:forEach>>
  										${i.name}</option>
  									</c:forEach>
									</select>
								</div>
							</div>
							</c:if>
							<c:if test="${op =='详情'}">
							<div class="am-form-group">
								<label class="am-u-md-2 am-text-right am-form-label" >包含服务</label>
								<div class="am-u-md-4 am-u-end">
									<select id="serviceSel" multiple disabled="disabled">
									<c:forEach items="${items}" var="i">
  										<option value="${i.serviceItemId}" <c:forEach items='${priceList}' var='entry'><c:if test="${i.serviceItemId == entry.key}">selected</c:if></c:forEach>>
  										${i.name}</option>
  									</c:forEach>
									</select>
								</div>
							</div>
							</c:if>
							<div class="am-form-group">
								<label class="am-u-sm-4 am-u-md-2 am-text-right am-form-label">服务名称</label>
								<label class="am-u-sm-4 am-u-md-2 am-text-center am-form-label">门店等级</label>
								<label class="am-u-sm-4 am-u-md-2 am-text-left am-form-label">会员价</label>
								<label class="am-u-md-2 am-u-end am-text-left am-form-label">非会员价</label>
							</div>
							<div id="itemDiv">
								<c:forEach items="${priceList}" var="entry" varStatus="s">
								<div id="${entry.key}">
								<c:forEach items="${entry.value}" var="p" varStatus="status">
								<div class="am-form-group" style="height: 35px">
									<c:choose>
										<c:when test="${not empty p.price}">
											<div class="am-u-sm-4 am-u-md-2 am-text-right am-form-label">												
												${p.price.serviceItemName}<input name="priceList[${s.index*shopGradesSize+status.index}].serviceItemId"
													type="hidden" value="${p.serviceItemId}">
											</div>
											<label class="am-u-sm-4 am-u-md-2 am-text-center am-form-label">
												<input type="checkbox" 
													class="needCkCls" title="请选择门店等级" checked="checked"> ${p.grade.name}
												<input name="priceList[${s.index*shopGradesSize+status.index}].shopGradeId"
													type="hidden" value="${p.grade.shopGradeId}">
											</label>
											<div class="am-u-sm-4 am-u-md-2">
												<input type="text"
													name="priceList[${s.index*shopGradesSize+status.index}].vipPrice"
													class="required isPriceOne am-input-sm" placeholder="请输入会员价"
													value="${p.price.vipPrice}">
											</div>
											<div class="am-u-md-2 am-u-end">
												<input type="text"
													name="priceList[${s.index*shopGradesSize+status.index}].noVipPrice"
													class="required isPriceOne am-input-sm" placeholder="请输入非会员价"
													value="${p.price.noVipPrice}">
											</div>
										</c:when>
										<c:otherwise>
											<div class="am-u-sm-4 am-u-md-2 am-text-right">												
												${p.itemName}<input name="priceList[${s.index*shopGradesSize+status.index}].serviceItemId"
													type="hidden" value="${p.itemId}" disabled="disabled">
											</div>
											<div class="am-u-sm-4 am-u-md-2">
												<input type="checkbox"
													class="needCkCls" title="请选择门店等级"> ${p.grade.name}
												<input name="priceList[${s.index*shopGradesSize+status.index}].shopGradeId"
													type="hidden" value="${p.grade.shopGradeId}"
													disabled="disabled">
											</div>
											<div class="am-u-sm-4 am-u-md-2">
												<input type="text"
													name="priceList[${s.index*shopGradesSize+status.index}].vipPrice"
													class="required isPriceOne am-input-sm" placeholder="请输入会员价"
													disabled="disabled">
											</div>
											<div class="am-u-md-2 am-u-end">
												<input type="text"
													name="priceList[${s.index*shopGradesSize+status.index}].noVipPrice"
													class="required isPriceOne am-input-sm" placeholder="请输入非会员价"
													disabled="disabled">
											</div>
										</c:otherwise>
									</c:choose>
								</div>
								</c:forEach>
								</div>
							</c:forEach>
							</div>
						</div>
						<div class="am-cf"></div>
					</div>
				</div>
				<div class="am-margin">
				<c:if test="${op!='详情'}">
					<button class="am-btn am-btn-primary am-btn-xs" type="submit"><span class="am-icon-check"></span> 保存</button>
				</c:if>
					<a href="javascript:;" onClick="javascript:history.back(-1);" class="am-btn am-btn-primary am-btn-xs"><span class="am-icon-times"></span> 取消</a>
				</div>
			</form>
		</div>
	</div>
	<%@include file="/WEB-INF/jsp/management/package/package.jspf"%>
</body>
</html>